Re: 8lgm's SCO "at" hole

Karl Strickland (karl@bagpuss.demon.co.uk)
Sat, 10 Dec 1994 13:51:29 +0000 (GMT)

> 
> 
> >AFAIK, getcwd(3) always calls /bin/pwd; but getwd(2) is a system call.
> >getcwd() is only provided for backwards compatibility; i suppose all new
> >code should be using getwd(2).
> 
> 
> Neither of the calls is a system call on any system that I'm aware of.

You're quite right - I stand corrected..

> Getcwd(3) is the thing POSIX wants you to use.
> Getwd() is to getcwd() what  gets() is to fgets() [ well, almost ].
> 
> When chosing between: getwd(char *buf) and getcwd(char *buf, size_t size_of_buf)
> the choice should be obvious.

I'm not so sure its as obvious as the choice between gets() & fgets().
eg: from SunOS 4.1.x getcwd() man page:

	BUGS
	     Since this function uses popen() to create a pipe to the pwd
	     command,  it  is  slower than getwd() and gives poorer error
	     diagnostics.  getcwd() is provided  only  for  compatibility
	     with other UNIX operating systems.

So - for me at least - getwd() would be the obvious choice here.  getwd()
isnt quite as bad as gets() - at least there is an upper bound on getwd()
(according to the documentation anyway, obviously not seen the src) of
MAXPATHLEN bytes.

> In SunOS 4.1.x, getcwd() does call /bin/pwd.
> In Solaris 2.x, getcwd() use /etc/mnttab and some tree traversal
> to find the current directory.  getwd is relegated to libucb.so and
> just calls getcwd(buf, MAXPATHLEN);

Whats getwd() in Solaris 2.x?  Does it just do getcwd(pathname, MAXPATHLEN) ?

Cheers
------------------------------------------+-----------------------------------
Mailed using ELM on FreeBSD               |                    Karl Strickland
PGP 2.3a Public Key Available.            | Internet: karl@bagpuss.demon.co.uk
                                          |